package com.generation.Bean;

import com.generation.utils.DateUtils;
import com.generation.utils.PropertiesUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author mockingjay
 * @date 2023/4/3 - 11:50
 */
public class Constants {
    /**
     * 是否忽略表前缀
     */
    public static Boolean IGNORE_TABLE_PREFIX;
    /**
     * 参数bean后缀
     */
    public static String SUFFIX_BEAN_PARMA;
    public static String SUFFIX_BEAN_QUERY_FUZZY;
    public static String SUFFIX_BEAN_QUERY_TIME_START;
    public static String SUFFIX_BEAN_QUERY_TIME_END;
    public static String SUFFIX_MAPPER;
    /**
     * 文件输出路径
     */
    public static String PATH_BASE;
    public static String PATH_POJO;
    public static String PATH_UTILS;
    public static String PATH_ENUM;
    public static String PATH_PARAM;
    public static String PATH_MAPPER;
    public static String PATH_MAPPER_XML;
    public static String PATH_SERVICE;
    public static String PATH_SERVICE_IMPL;
    public static String PATH_CONTROLLER;
    public static String PATH_APPLICATION;
    /**
     * 包名
     */
    public static String PACKAGE_BASE;
    public static String PACKAGE_PO;
    public static String PACKAGE_UTILS;
    public static String PACKAGE_ENUM;
    public static String PACKAGE_PARAM;
    public static String PACKAGE_MAPPER;
    public static String PACKAGE_SERVICE;
    public static String PACKAGE_SERVICE_IMPL;
    public static String PACKAGE_CONTROLLER;
    /**
     * mian目录下java目录
     */
    public static final String PATH_JAVA = "java";
    /**
     * mian目录下resource目录
     */
    public static final String PATH_RESOURCE = "resources";
    /**
     * author名字
     */
    public static String AUTHOR;
    /**
     * 需要忽略的属性,注解，包名
     */
    public static String IGNORE_BEAN_TOJSON_FIELD;
    public static String IGNORE_BEAN_TOJSON_EXPRESSION;
    public static String IGNORE_BEAN_TOJSON_CLASS;
    /**
     * 日期序列化
     */
    public static String BEAN_DATE_FORMAT_EXPRESSION;
    public static String BEAN_DATE_FORMAT_CLASS;
    /**
     * 日期反序列化
     */
    public static String BEAN_DATE_UNFORMAT_EXPRESSION;
    public static String  BEAN_DATE_UNFORMAT_CLASS;
    /**
     * java类型
     */
    public final static String[] SQL_DATE_TIME_TYPE = new String[]{"datetime", "timestamp"};
    public final static String[] SQL_DATE_TYPE = new String[]{"date"};
    public final static String[] SQL_DECIMAL_TYPE = new String[]{"decimal", "double", "float"};
    public final static String[] SQL_STRING_TYPE = new String[]{"char", "varchar", "text", "mediumtext", "longtext"};
    public final static String[] SQL_INTEGER_TYPE = new String[]{"int", "tinyint"};
    public final static String[] SQL_LONG_TYPE = new String[]{"bigint"};

    /**
     * 模板
     */
    public final static String TEMPLATE_MAPPER;
    public final static String TEMPLATE_MAPPER_XML;
    public final static String TEMPLATE_PAGEUTILS;
    public final static String TEMPLATE_DATETIMEPATTERNENUM;
    public final static String TEMPLATE_DATEUTILS;
    public final static String TEMPLATE_QUERYUTILS;
    public final static String TEMPLATE_SERVICE;
    public final static String TEMPLATE_CONTSANTS;
    public final static String TEMPLATE_SERVICE_IMPL;
    public final static String TEMPLATE_R;
    public final static String TEMPLATE_CONTROLLER;
    public final static String TEMPLATE_APPLICATION_CONFIG;
    /**
     * 模板数据
     */
    public final static Map<String,Object> TEMPLATE_DATA=new HashMap<>();
    public final static Map<String,Object> TEMPLATE_MAPPER_XML_DATA=new HashMap<>();
    public final static Map<String,Object> TEMPLATE_BASE_DATA=new HashMap<>();
    public final static Map<String,Object> TEMPLATE_SERVICE_DATA=new HashMap<>();
    public final static Map<String,Object> TEMPLATE_SERVICE_IMPL_DATA=new HashMap<>();
    public final static Map<String,Object> TEMPLATE_CONTROLLER_DATA=new HashMap<>();
    public final static Map<String,Object> TEMPLATE_APPLICATION_CONFIG_DATA=new HashMap<>();
    /**
     * 项目名
     */
    public static String PRONAME;
    static {
        //作者
        AUTHOR = PropertiesUtils.getString("author.comment");
        //后缀
        IGNORE_TABLE_PREFIX = Boolean.valueOf(PropertiesUtils.getString("ignore.table.prefix"));
        SUFFIX_BEAN_PARMA = PropertiesUtils.getString("suffix.bean.param");
        SUFFIX_BEAN_QUERY_FUZZY=PropertiesUtils.getString("suffix.bean.query.fuzzy");
        SUFFIX_BEAN_QUERY_TIME_START=PropertiesUtils.getString("suffix.bean.query.time.start");
        SUFFIX_BEAN_QUERY_TIME_END=PropertiesUtils.getString("suffix.bean.query.time.end");
        SUFFIX_MAPPER=PropertiesUtils.getString("suffix.mapper");
        //项目名
        PRONAME=PropertiesUtils.getString("proName");
        //package初始化
        PACKAGE_BASE = PropertiesUtils.getString("package.base");
        PACKAGE_PO = PACKAGE_BASE + "." + PropertiesUtils.getString("package.pojo");
        PACKAGE_UTILS=PACKAGE_BASE+"."+PropertiesUtils.getString("package.utils");
        PACKAGE_ENUM=PACKAGE_BASE+'.'+PropertiesUtils.getString("package.enum");
        PACKAGE_PARAM=PACKAGE_BASE+'.'+PropertiesUtils.getString("package.param");
        PACKAGE_MAPPER=PACKAGE_BASE+'.'+PropertiesUtils.getString("package.mapper");
        PACKAGE_SERVICE=PACKAGE_BASE+'.'+PropertiesUtils.getString("package.service");
        PACKAGE_SERVICE_IMPL=PACKAGE_SERVICE+'.'+PropertiesUtils.getString("package.serviceImpl");
        PACKAGE_CONTROLLER=PACKAGE_BASE+'.'+PropertiesUtils.getString("package.controller");
        //path路径初始化
        PATH_BASE = PropertiesUtils.getString("path.base") + PATH_JAVA;
        PATH_POJO = PATH_BASE + '/' + PACKAGE_PO.replace(".", "/");
        PATH_UTILS=PATH_BASE+'/'+PACKAGE_UTILS.replace(".","/");
        PATH_ENUM=PATH_BASE+'/'+PACKAGE_ENUM.replace(".","/");
        PATH_PARAM=PATH_BASE+'/'+PACKAGE_PARAM.replace(".","/");
        PATH_MAPPER=PATH_BASE+'/'+PACKAGE_MAPPER.replace(".","/");
        PATH_SERVICE=PATH_BASE+'/'+PACKAGE_SERVICE.replace(".","/");
        PATH_MAPPER_XML=PropertiesUtils.getString("path.base")+PATH_RESOURCE+"/"+PropertiesUtils.getString("package.mapper");
        PATH_APPLICATION=PropertiesUtils.getString("path.base")+PATH_RESOURCE;
        PATH_SERVICE_IMPL=PATH_BASE+'/'+PACKAGE_SERVICE_IMPL.replace(".","/");
        PATH_CONTROLLER=PATH_BASE+'/'+PACKAGE_CONTROLLER.replace(".","/");
        //是否忽略属性
        IGNORE_BEAN_TOJSON_FIELD=PropertiesUtils.getString("ignore.bean.tojson.field");
        IGNORE_BEAN_TOJSON_EXPRESSION=PropertiesUtils.getString("ignore.bean.tojson.expression");
        IGNORE_BEAN_TOJSON_CLASS=PropertiesUtils.getString("ignore.bean.tojson.class");
        //日期序列化
        BEAN_DATE_FORMAT_EXPRESSION=PropertiesUtils.getString("bean.date.format.expression");
        BEAN_DATE_FORMAT_CLASS=PropertiesUtils.getString("bean.date.format.class");
        //日期但序列化
        BEAN_DATE_UNFORMAT_EXPRESSION=PropertiesUtils.getString("bean.date.unformat.expression");
        BEAN_DATE_UNFORMAT_CLASS=PropertiesUtils.getString("bean.date.unformat.class");
        //获取模板列表
        TEMPLATE_MAPPER="template/Dao.java.vm";
        TEMPLATE_MAPPER_XML="template/Dao.xml.vm";
        TEMPLATE_PAGEUTILS="template/PageUtils.java.vm";
        TEMPLATE_DATETIMEPATTERNENUM="template/DateTimePatternEnum.java.vm";
        TEMPLATE_DATEUTILS="template/DateUtils.java.vm";
        TEMPLATE_SERVICE="template/Service.java.vm";
        TEMPLATE_QUERYUTILS="template/QueryUtils.java.vm";
        TEMPLATE_CONTSANTS="template/Constants.java.vm";
        TEMPLATE_SERVICE_IMPL="template/ServiceImpl.java.vm";
        TEMPLATE_R="template/R.java.vm";
        TEMPLATE_CONTROLLER="template/Controller.java.vm";
        TEMPLATE_APPLICATION_CONFIG="template/application.yml.vm";
        //获取mppper模板数据
        TEMPLATE_DATA.put("mapperPackageName",Constants.PACKAGE_MAPPER);
        TEMPLATE_DATA.put("poPackageName",Constants.PACKAGE_PO);
        TEMPLATE_DATA.put("author",Constants.AUTHOR);
        //获取mapperXml模板书据
        TEMPLATE_MAPPER_XML_DATA.put("mapperPackageName",Constants.PACKAGE_MAPPER);
        TEMPLATE_MAPPER_XML_DATA.put("poPackageName",Constants.PACKAGE_PO);
        //获取基础类的模板数据
        TEMPLATE_BASE_DATA.put("PageUtils","PageUtils");
        TEMPLATE_BASE_DATA.put("author",Constants.AUTHOR);
        TEMPLATE_BASE_DATA.put("datetime", DateUtils.getNowDate());
        TEMPLATE_BASE_DATA.put("DateTimePatternEnum","DateTimePatternEnum");
        TEMPLATE_BASE_DATA.put("DateUtils","DateUtils");
        TEMPLATE_BASE_DATA.put("basePackage",Constants.PACKAGE_BASE);
        TEMPLATE_BASE_DATA.put("Query","Query");
        TEMPLATE_BASE_DATA.put("Constants","Constants");
        TEMPLATE_BASE_DATA.put("R","R");
        //获取Service的模板数据
        TEMPLATE_SERVICE_DATA.put("author",Constants.AUTHOR);
        TEMPLATE_SERVICE_DATA.put("datetime", DateUtils.getNowDate());
        TEMPLATE_SERVICE_DATA.put("basePackage",Constants.PACKAGE_BASE);
        //获取ServiceImpl的模板数据
        TEMPLATE_SERVICE_IMPL_DATA.put("basePackage",Constants.PACKAGE_BASE);
        TEMPLATE_SERVICE_IMPL_DATA.put("author",Constants.AUTHOR);
        //获取controller的模板数据
        TEMPLATE_CONTROLLER_DATA.put("author",Constants.AUTHOR);
        TEMPLATE_CONTROLLER_DATA.put("datetime", DateUtils.getNowDate());
        TEMPLATE_CONTROLLER_DATA.put("basePackage",Constants.PACKAGE_BASE);
        TEMPLATE_CONTROLLER_DATA.put("proName",PRONAME);
        //获取application配置文件数据
        TEMPLATE_APPLICATION_CONFIG_DATA.put("datasourceType",PropertiesUtils.getString("datasourceType"));
        TEMPLATE_APPLICATION_CONFIG_DATA.put("driverName",PropertiesUtils.getString("db.driver.name"));
        TEMPLATE_APPLICATION_CONFIG_DATA.put("url",PropertiesUtils.getString("db.url"));
        TEMPLATE_APPLICATION_CONFIG_DATA.put("username",PropertiesUtils.getString("db.username"));
        TEMPLATE_APPLICATION_CONFIG_DATA.put("password",PropertiesUtils.getString("db.password"));
        TEMPLATE_APPLICATION_CONFIG_DATA.put("port",PropertiesUtils.getString("port"));
    }

}
